<?php
// 连接 swoole服务
$client = new swoole_client(SWOOLE_SOCK_TCP);
if (!$client->connect('127.0.0.1', 9501, -1)) {
    exit("连接失败: {$client->errCode}\n");
}
//echo $client->recv();
fwrite(STDOUT, '请输入消息:');
$msg = trim(fgetss(STDIN));

// 发送消息给swoole服务端
$client->send($msg);

// 接收服务器消息
$ret = $client->recv();
echo $ret;